package com.robam.cloud.authcenter.manager;

import com.robam.cloud.authcenter.helper.WechatAccessTokenGateway;
import com.robam.cloud.authcenter.helper.WechatJspApiTicketGateway;
import com.robam.cloud.authcenter.helper.impl.WechatAccessTokenDealKeyGateway;
import com.robam.cloud.authcenter.helper.impl.WechatAccessTokenOriginGateway;
import com.robam.cloud.authcenter.helper.impl.WechatJspApiTicketDealKeyGateway;
import com.robam.cloud.authcenter.helper.impl.WechatJspApiTicketOriginGateway;
import com.robam.cloud.common.bean.restful.entity.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class WechatAccessTokenManager {

    @Autowired
    WechatAccessTokenOriginGateway wechatAccessTokenOriginGateway;
    @Autowired
    WechatAccessTokenDealKeyGateway wechatAccessTokenDealKeyGateway;
    @Autowired
    WechatJspApiTicketOriginGateway wechatJspApiTicketOriginGateway;
    @Autowired
    WechatJspApiTicketDealKeyGateway wechatJspApiTicketDealKeyGateway;

    public WechatAccessTokenGateway callAccessTokenMeth(String AccessTokenType) {
        WechatAccessTokenGateway wechatAccessTokenGateway = null;
        if ("1".equals(AccessTokenType)) {
            wechatAccessTokenGateway = wechatAccessTokenOriginGateway;
        } else if ("2".equals(AccessTokenType)) {
            wechatAccessTokenGateway = wechatAccessTokenDealKeyGateway;
        } else {
            throw new ServiceException("三方平台类型无法识别");
        }
        return wechatAccessTokenGateway;
    }

    public WechatJspApiTicketGateway callJspApiTicketMeth(String AccessTokenType) {
        WechatJspApiTicketGateway wechatJspApiTicketGateway = null;
        if ("1".equals(AccessTokenType)) {
            wechatJspApiTicketGateway = wechatJspApiTicketOriginGateway;
        } else if ("2".equals(AccessTokenType)) {
            wechatJspApiTicketGateway = wechatJspApiTicketDealKeyGateway;
        } else {
            throw new ServiceException("三方平台类型无法识别");
        }
        return wechatJspApiTicketGateway;
    }
}
